package com.zmj.mobile.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zmj.framework.base.service.impl.BaseServiceImpl;
import com.zmj.mobile.entity.OrgUserEntity;
import com.zmj.mobile.mapper.IOrgUserMapper;
import com.zmj.mobile.service.IOrgUserService;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>

 * </p>
 *
 * @author lzy
 * @since 2024-02-01
 */
@Service
public class OrgUserServiceImpl extends BaseServiceImpl<IOrgUserMapper, OrgUserEntity> implements IOrgUserService {


    public List<OrgUserEntity> getByOrgId(Integer orgId) {
        LambdaQueryWrapper<OrgUserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(OrgUserEntity::getOrgId, orgId);
        queryWrapper.eq(OrgUserEntity::getIsDeleted, 0);

        return baseMapper.selectList(queryWrapper);
    }

    public OrgUserEntity getOrgIdByUserId(Integer userId) {
        LambdaQueryWrapper<OrgUserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(OrgUserEntity::getUserId, userId);
        queryWrapper.eq(OrgUserEntity::getIsDeleted, 0);
        queryWrapper.last("limit 1");

        return baseMapper.selectOne(queryWrapper);
    }
}
